#!/bin/sh

#set -e

orgdir=`pwd`

echo "release no:"
read rel

echo "progname: (smartcard20):"
read progname
if [ "x${progname}" = "x" ] ; then
	progname=smartcard20
fi


OUTPATH=../../releases/
PROGPATH=${OUTPATH}/${progname}-${rel}

echo "tag in svn ( svn cp https://hardtokenmgmt.svn.sourceforge.net/svnroot/hardtokenmgmt/smartcard20/trunk https://hardtokenmgmt.svn.sourceforge.net/svnroot/hardtokenmgmt/smartcard20/tags/${progname}-${rel}) (Y/n)"
read tagsvn
if [ "x$tagsvn" == "xy" -o "x$tagsvn" == "xY" -o "x$tagsvn" == "x" ] ; then
	svn cp https://hardtokenmgmt.svn.sourceforge.net/svnroot/hardtokenmgmt/smartcard20/trunk https://hardtokenmgmt.svn.sourceforge.net/svnroot/hardtokenmgmt/smartcard20/tags/${progname}-${rel}
fi

svn export . ${PROGPATH}

zipname="${progname}-${rel}.zip"
cd ${OUTPATH}
zip -r ${zipname} ${progname}-${rel}


md5sum ${zipname}          > ${zipname}.md5
sha1sum ${zipname}         > ${zipname}.sha1
gpg -o ${zipname}.gpg -sab   ${zipname} 

cd $orgdir
ls -la ${PROGPATH} ${OUTPATH}/${zipname} ${OUTPATH}/${zipname}.md5 ${OUTPATH}/${zipname}.sha1 ${OUTPATH}/${zipname}.gpg

echo "push to sf? (Y/n)"
read pushsf
if [ "x$pushsf" == "xy" -o "x$pushsf" == "xY" -o "x$pushsf" == "x" ] ; then
	echo "cd /home/pfs/project/h/ha/hardtokenmgmt"
	echo "ls "
	sftp kinneh,hardtokenmgmt@web.sourceforge.net
fi

